<!--
 * @Author: daidai
 * @Date: 2022-03-01 15:27:58
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-05-07 11:24:14
 * @FilePath: \web-pc\src\pages\big-screen\view\indexs\right-center.vue
-->
<template>
  <div v-if="pageflag" class="right_center_wrap beautify-scroll-def" :class="{ 'overflow-y-auto': !workRecordsSwiperFlag }">
    
      <ul class="right_center ">
        <li class="right_center_header" style="position: -webkit-sticky; position: sticky; top: 0; z-index: 1;">
          <div class="inner_right">
            <div class="flex" style="font: bolder; font-size: large; color: #000;">
              <div class="info" style="width: 80px; margin-left: 80px;">时间</div>
              <div class="info" style="width: 60px; margin-left: -15px">设备码</div>
              <div class="info" style="width: 60px; margin-left: 10px">详情</div>
            </div>
          </div>
        </li>

        <component :is="components" :data="list" :class-option="defaultOption">
          <li class="right_center_item" v-for="(item, i) in list" :key="i">
            <span class="orderNum">{{ i + 1 }}</span>
            <div class="inner_right">
              <div class="dibu"></div>
              <div class="flex">
                <div class="info">
                  <span class="contents zhuyao"> {{ item.beginTime }}</span>
                </div>
                <!-- <div class="info">
                  <span
                    class="doudong"
                    :class="{
                      typeRed: item.statusCode == 0,
                      typeYellow: item.statusCode == 1,
                      typeGreen: item.statusCode == 2,
                      typeBlue: item.statusCode == 3,
                    }"
                    >{{ deviceStatusHandled(item) }}</span
                  >
                </div> -->
                <div class="info">
                  <span class="contents warning"> {{ item.robotCode }}</span>
                </div>
                <div class="info">
                  <span class="contents warning"> {{ item.message }}</span>
                </div>
              </div>


              <!-- <div class="flex">
                <div class="info">
                  <span class="labels"> 地址：</span>
                  <span class="contents ciyao" style="font-size:12px"> {{ item.provinceName }}/{{ item.cityName }}/{{ item.countyName }}</span>
                </div>
                <div class="info time">
                  <span class="labels">时间：</span>
                  <span class="contents" style="font-size:12px"> {{ item.createtime }}</span>
                </div>
              </div> -->

              <!-- <div class="flex">
                <div class="info">
                  <span class="labels">任务详情：</span>
                  <span class="contents ciyao" :class="{ warning: item.alertdetail }"> {{ item.alertdetail || '无'
                  }}</span>
                </div>
              </div> -->
            </div>
          </li>
        </component>
      </ul>
  </div>
  <Reacquire v-else @onclick="getData" style="line-height:200px" />

</template>

<script>
import { currentGET } from 'api/modules'
import vueSeamlessScroll from 'vue-seamless-scroll'  // vue2引入方式
import Kong from '../../components/kong.vue'
export default {
  components: { vueSeamlessScroll, Kong },

  data() {
    return {
      list: [],
      pageflag: true,
      defaultOption: {
        ...this.$store.state.setting.defaultOption,
        limitMoveNum: 3, 
        singleHeight: 250, 
        step:0,
      }

    };
  },
  computed: {
    workRecordsSwiperFlag() {
      let ssyjSwiper = this.$store.state.setting.ssyjSwiper
      if (ssyjSwiper) {
        this.components = vueSeamlessScroll
      } else {
        this.components = Kong
      }
      return ssyjSwiper
    }
  },
  created() {
    this.getData()
  },

  mounted() { },
  methods: {
    deviceStatusHandled(item) {      
      let statuses = ["失败", "进行中", "成功", "异常"];      
      return statuses[item.statusCode];
    },
    getData() {
      this.pageflag = true
      // this.pageflag =false
      // currentGET('big5', { limitNum: 50 }).then(res => {
      currentGET('agvWarnings', { limitNum: 5 }).then(res => {
        console.log('AGV报警', res);
        // if (res.success) {
        if (!res.code) {
          this.list = res.data;
          let timer = setTimeout(() => {
              clearTimeout(timer)
              this.defaultOption.step=this.$store.state.setting.defaultOption.step
          }, this.$store.state.setting.defaultOption.waitTime);
        } else {
          this.pageflag = false
          this.$Message.warning(res.msg)
        }
      })
    },
  },
};
</script>
<style lang='scss' scoped>
.right_center {
  width: 100%;
  height: 100%;

  .right_center_header {
    background-color: #1d3477; /* 设置背景颜色 */
    padding: 8px;
    border-bottom: 1px solid #ddd; /* 可选：为标题行添加下边框 */
    font-weight: bold;
    z-index: 1; /* 确保标题行位于其他内容之上 */

    .info {
      margin-right: 10px;
      display: flex;
      align-items: center;
      color: aqua;

      .labels {
        flex-shrink: 0;
        font-size: 14px;
        color: #333;
      }
    }
  }

  .right_center_item {
    display: flex;
    align-items: center;
    justify-content: center;
    height: auto;
    padding: 10px;
    font-size: 14px;
    color: #fff;

    .orderNum {
      margin: 0 20px 0 -20px;
    }

    .doudong {
      //  vertical-align:middle;
      overflow: hidden;
      -webkit-backface-visibility: hidden;
      -moz-backface-visibility: hidden;
      -ms-backface-visibility: hidden;
      backface-visibility: hidden;
    }

    .inner_right {
      position: relative;
      height: 100%;
      width: 400px;
      flex-shrink: 0;
      line-height: 1.5;

      .dibu {
        position: absolute;
        height: 2px;
        width: 104%;
        background-image: url("../../assets/img/zuo_xuxian.png");
        bottom: -12px;
        left: -2%;
        background-size: cover;
      }
    }

    .info {
      margin-right: 10px;
      display: flex;
      align-items: center;

      .labels {
        flex-shrink: 0;
        font-size: 12px;
        color: rgba(255, 255, 255, 0.6);
        // color: #fff;
      }

      .zhuyao {
        // color: $primary-color;
        color: #fff;
        font-size: 15px;
        margin-left: 53px;
      }

      .ciyao {
        color: rgba(255, 255, 255, 0.8);
      }

      .warning {
        // color: #E6A23C;
        color: #fff;
        font-size: 15px;
      }
    }

    .typeRed {
      // color: #fc1a1a;
      color: #fff;
    }

    .typeGreen {
      // color: #0ef30e;
      color: #fff;
    }
    .typeYellow {
      // color: #eaee10;
      color: #fff;
    }

    .typeBlue {
      // color: #1d21f5;
      color: #fff;
    }

  }
}

.right_center_wrap {
  overflow: hidden;
  height: 250px;
}

.overflow-y-auto {
  overflow-y: auto;
}
</style>